<?php

require "include/bittorrent.php";
dbconn();
loggedinorreturn();
$HTMLOUT = "";
$order = isset($_GET['a']) && is_valid_id($_GET['a']) ? $_GET['a'] : 0;
if ($order == 1)
	$order = 'asc';
else
	$order = 'desc';
$HTMLOUT .="<a href='bet.php'><img src='betting.png' alt='Bet' title='博彩' width='400' height='125' /></a>
<h1>博彩频道</h1>
<table class='main' cellspacing='0' cellpadding='5' border='0'>
<tr>
<td align='center' class='navigations'><a href='bet.php'>当前竞猜</font></a></td>
<td align='center' class='navigations'><a href='bet_old.php'>闭盘竞猜</a></td>";
if ($CURUSER['class'] >= UC_MODERATOR || $CURUSER['id'] == $betsadmin) {
	$HTMLOUT .= "<td align='center' class='navigations'><a href='bet_admin.php'>管理竞猜</a></td>";
}
$HTMLOUT .="<td align='center' class='navigations'><a href='bet_coupon.php'>我的押注</a></td>
<td align='center' class='navigations'><a href='bet_bonustop.php'><font color='red'>用户排名</a></td>
<td align='center' class='navigations'><a href='bet_info.php'>系统帮助</a></td>
</tr></table><br />";
$res = sql_query("SELECT * FROM bettop WHERE userid = " . sqlesc($CURUSER['id']) . "") or sqlerr(__FILE__, __LINE__);
while ($arr = mysql_fetch_assoc($res)) {
	$HTMLOUT .="<table border='1' cellspacing='0' cellpadding='5'>\n";
	$HTMLOUT .="<tr><td class='colhead' align='left'>用户名</td><td class='colhead' align='left'>魔力值 +/-</td></tr>\n";
	$HTMLOUT .="<tr><td><a href='userdetails.php?id=$CURUSER[id]'>" . htmlspecialchars($CURUSER["username"]) . "</a></td><td align='right'><b>" . htmlspecialchars($arr["bonus"]) . " 魔力值</b></td></tr></table>\n";
}
$number = 0;
$res = sql_query("SELECT users.username, bettop.userid, bettop.bonus FROM bettop INNER JOIN users ON bettop.userid = users.id ORDER BY bettop.bonus $order LIMIT 50") or sqlerr(__FILE__, __LINE__);
$HTMLOUT.="<h1>用户排名</h1>\n";
if ($order == "desc")
	$HTMLOUT .= "<h2><font color='#999999'>赢家</font> - <a href='bet_bonustop.php?a=1'>输家</a></h2>";
else
	$HTMLOUT .= "<h2><a href='bet_bonustop.php?a=2'>赢家</a> - <font color='#999999'>输家</font></h2>";
$HTMLOUT .="<table border='1' cellspacing='0' cellpadding='5'>\n";
$HTMLOUT .="<br /><tr><td class='colhead' align='left'>排名</td><td class='colhead' align='left'>用户名</td><td class='colhead' align='left'>魔力值 +/-</td></tr>\n";
while ($arr = mysql_fetch_assoc($res)) {
	$number++;
	$HTMLOUT .="<tr><td>#" . htmlspecialchars($number) . "</td><td><a href='userdetails.php?id=$arr[userid]'>" . htmlspecialchars($arr["username"]) . "</a></td><td align='right'><b>" . htmlspecialchars($arr["bonus"]) . " 魔力值</b></td></tr>\n";
}
$HTMLOUT .="</table>";
stdhead('博彩');
print $HTMLOUT;
stdfoot();
